﻿@using KMF.Common;
@using KMF.WebUI
@using KMF.WebUI.Infrastructure
@using KMF.WebUI.Models
@model List<ProductCategoryMenuLeftDto>
@{
    var listNewsCategory = (List<NewsTitleDto>)ViewBag.News;
    var cateId = (int)ViewBag.CateId;
    var newsId = ViewBag.NewsId;
    var pcate = ViewBag.pCate;
}


<div class="header_first">
    <div class="header_left">
        <ul>
            @if (Session[SessionConfig.SessionCustomerLogin] != null)
            {
                var customerInfo = (CustomerInfo)Session[SessionConfig.SessionCustomerLogin];
                <li>
                    <span class="cl-sub-orange">Xin chào, @customerInfo.FullName</span>
                    <a href="@Url.Action("Logout", "Login")">(Đăng xuất)</a>
                </li>
            }
            else
            {
                <li>
                    <a href="@Url.Action("Index", "Login", new { })" rel="nofollow">Đăng nhập</a>
                </li>
            }
            <li><a href="@Url.Action("Register", "Login", new { })">Đăng kí</a></li>
            <li><a href="@Url.Action("Index", "Contact")">Hỗ trợ trực tuyến</a> <span class="yahoo"></span></li>
        </ul>
        <div class="header_share"></div>
    </div>
    <a href="@Url.Action("Index", "Home", new { })" class="header_logo"></a>
    <div class="header_right">
        @using (Html.BeginForm("RidirectSearch", "Search", FormMethod.Post))
        {
            <div class="searchbar">
                <input type="text" name="keyword" class="input_search" />
                <input type="submit" class="searchbutton" />
            </div>
        }
        <div class="header_service">
            <div class="trans"><span class="trans_icon"></span><a href="@Url.Action("About", "News", new { cateId = 4 })">Giao hàng</a></div>
            <div class="cart">
                <span class="cart_icon"></span>
                @if (Session[SessionConfig.SessionCartInfor] != null)
                {
                    var cartInfo = (OrderInfo)Session[SessionConfig.SessionCartInfor];
                    <a href="@Url.Action("Finish", "Order")" rel="nofollow" id="shopCartList">
                        <i class="home-layout"></i>
                        Giỏ hàng [@cartInfo.ProductOrderList.Count]
                    </a>
                }
                else
                {
                    <a href="@Url.Action("Index", "Order")" rel="nofollow">
                        <i class="home-layout"></i>
                        Giỏ hàng [0]
                    </a>
                }
            </div>
        </div>
    </div>
</div>
</div>
<div class="nav">
    <div style="width: 890px; margin: 0 auto">
        <ul class="nav_menu">
            <li class="nav_menu_item  "><a id="home" class="home_menu nav_item" href="@Url.Action("Index", "Home", new { })">Trang Chủ</a></li>
            <li class="nav_menu_item "><a id="intro" class="about_menu nav_item" href="@Url.Action("About", "News", new { cateId = 2 })">Giới Thiệu</a></li>
            <li class="nav_menu_item "><a id="product" class="product_menu nav_item" href="@Url.Action("Index", "CategoryL1", new {cateId=3,cateName="San-Pham" })">Sản Phẩm</a>
                <ul class="service_multi_menu" style="width: 378px !important">

                    @if (Model.Any())
                    {
                        var css = "";
                        var parentCategory = Model.Where(c => c.ParentId == "0");

                        if (parentCategory.Any())
                        {
                            foreach (var c in parentCategory)
                            {
                                var lnkCate = Url.Action("Index", "CategoryL1", new { cate = c.Id , cateName = c.Name });
                                css = "";
                                var childrenCategory = Model.Where(pc => pc.ParentId == c.Id);
                
                        <li class="sub_product" style="width: 358px!important;">

                            <a class="parent_product" href="@lnkCate">@c.Name</a>

                            @if (childrenCategory.Any())
                            {
                                <div class="sub_product_menu">
                                    <ul>
                                        @foreach (var child in childrenCategory)
                                        {
                                            var lnkChildCate = Url.Action("ProductByCateL2", "CategoryL1", new { cateId = child.Id, catefil = "OEJHY", cateName = child.Name });
                                            css = "";
                                
                                            <li style="width: auto!important;">

                                                <a href="@lnkChildCate">@child.Name</a>

                                            </li>
                                        }
                                    </ul>
                                </div>
                            }

                        </li>
                            }
                        }

                    }

                </ul>
            </li>
            <li class="nav_menu_item "><a id="service" class="service_menu nav_item" href="#">Dịch Vụ</a>
                <ul class="service_multi_menu">
                    @if (listNewsCategory.Any())
                    {

                        foreach (var item in listNewsCategory)
                        {
                        <li>
                            <a href="@Url.Action("Index", "News", new { cateId = cateId, newsId = item.Id, newstitle = KMF.Utility.StringUtil.RemoveSpecialCharactersVn(item.Title) })" title="@item.Title">
                                @item.Title
                            </a>
                        </li>
                        }
                    }
                    <li><a href="@Url.Action("Index", "Contact")">Tư vấn mua online</a></li>
                </ul>
            </li>
            <li class="nav_menu_item "><a id="contact" class="contact_menu nav_item" href="@Url.Action("Contact", "News", new { cateId = 3 })">Liên Hệ</a></li>
        </ul>
    </div>
</div>